//
//  didPepayViewController.m
//  OneCreditTreasure
//
//  Created by iOS Grouper on 16/8/30.
//
//

#import "didPepayViewController.h"
#import "didRepayTableViewCell.h"
#import "RepayDidViewController.h"//didcell
#import "OrderDetailViewController.h"//订单详情
@interface didPepayViewController ()<UITableViewDelegate,UITableViewDataSource>
{
    UITableView *myTableView;
    UIButton *payButton;
    UIView *headView;
    UILabel *titleL;
    UIImageView *nextImageView;
}


@end

@implementation didPepayViewController
- (void)viewWillAppear:(BOOL)animated{
    self.tabBarController.tabBar.hidden = YES;
}
- (void)viewWillDisappear:(BOOL)animated{
    self.tabBarController.tabBar.hidden = NO;
}

- (void)headView{
    headView = [UIView new];
    [self.view addSubview:headView];
    [headView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.view);
        make.height.mas_offset(40 * AUTO_HEIGHT);
        make.left.mas_equalTo(self.view);
        make.width.mas_equalTo(self.view);
        
    }];
    headView.backgroundColor= [UIColor whiteColor];
    headView.layer.borderColor = [UIColor blackColor].CGColor;
    headView.layer.borderWidth = 1;
    
    
    
    titleL = [UILabel new];
    [headView addSubview:titleL];
    [titleL mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerYWithinMargins.mas_equalTo(headView.mas_centerY);
        make.centerXWithinMargins.mas_equalTo(headView.mas_centerX);
        make.height.mas_equalTo(15 * AUTO_HEIGHT);
        
    }];
       titleL.textAlignment = NSTextAlignmentCenter;
    titleL.text = @"保时捷-Boxster";
    titleL.textColor  =HS;
    titleL.font = [UIFont fontWithName:ZIXING size:15 * AUTO_HEIGHT];
    
    
    
    nextImageView = [UIImageView new];
    [headView addSubview:nextImageView];
    [nextImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(headView.mas_right).offset(-10);
        make.size.mas_equalTo(CGSizeMake(30 * AUTO_WIDTH, 30*AUTO_HEIGHT));
        make.centerYWithinMargins.mas_equalTo(headView);
        
    }];
    nextImageView.backgroundColor = [UIColor redColor];
    
    nextImageView.userInteractionEnabled = YES;
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(TapAction:)];
    [nextImageView addGestureRecognizer:tap];
    
    
    
}

- (void)TapAction:(UITapGestureRecognizer *)TAP{
    OrderDetailViewController *order = [OrderDetailViewController new];
    [self.navigationController pushViewController:order animated:YES];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    payButton = [UIButton new];
    // Do any additional setup after loading the view.
    self.title = @"还款详情";
    self.view.backgroundColor = LV;
    [self headView];
    myTableView = [UITableView new];
    [self.view addSubview:myTableView];
    myTableView.backgroundColor = LV;
    myTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    [myTableView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.view).offset(40 * AUTO_HEIGHT);
        make.left.mas_equalTo(self.view);
        make.width.mas_equalTo(kScreenW);
        make.height.mas_equalTo(kScreenH);
        
    }];
    myTableView.delegate = self;
    myTableView.dataSource = self;
    [myTableView registerClass:[didRepayTableViewCell class] forCellReuseIdentifier:@"didRepayTableViewCell"];
    
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 5;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
     didRepayTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"didRepayTableViewCell"];
    cell.backgroundColor = LV;
    if (indexPath.row == 0) {
        [cell.backView addSubview:payButton];
        
        [payButton mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(cell.backView);
            make.right.mas_equalTo(cell.backView.mas_right);
            make.width.mas_equalTo(50 * AUTO_WIDTH);
            make.bottom.mas_equalTo(cell.backView);
            
        }];
        payButton.backgroundColor = [UIColor blackColor];
        
        payButton.backgroundColor = ZITI;
        payButton.alpha = 0.4;
        myBtnSettings(1, [UIColor lightGrayColor].CGColor,[UIColor blackColor] , 0, payButton);
        [payButton setTitle:@"立即还款" forState:UIControlStateNormal];
        payButton.titleLabel.font = [UIFont fontWithName:ZIXING size:13];
        [payButton sizeToFit];
        [payButton addTarget:self action:@selector(payBut:) forControlEvents:UIControlEventTouchUpInside];
    }
    
    
   
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    return cell;
}

//- (void)payBut:(UIButton *)btu{
//    
//    NSLog(@"vfdsf");
//    RepayDidViewController *repay = [RepayDidViewController new];
//    [self.navigationController pushViewController:repay animated:YES];
//}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 120 * AUTO_HEIGHT;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.row == 0) {
        RepayDidViewController *repay = [RepayDidViewController new];
        [self.navigationController pushViewController:repay animated:YES];
    }
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
